$OpenBSD: patch-source3_smbd_statvfs_c,v 1.1 2012/04/16 21:58:34 sthen Exp $
--- source3/smbd/statvfs.c.orig	Sat Apr  7 14:23:20 2012
+++ source3/smbd/statvfs.c	Tue Apr 10 23:49:12 2012
@@ -49,10 +49,8 @@ static int linux_statvfs(const char *path, vfs_statvfs
 	}
 	return result;
 }
-#endif
+#elif defined(DARWINOS)
 
-#if defined(DARWINOS)
-
 #include <sys/attr.h>
 
 static int darwin_fs_capabilities(const char * path)
@@ -125,8 +123,45 @@ static int darwin_statvfs(const char *path, vfs_statvf
 
 	return 0;
 }
+#elif defined(BSD) && defined(BSD_STATVFS_BSIZE)
+static int bsd_statvfs(const char *path, vfs_statvfs_struct *statbuf)
+{
+	struct statfs statfs_buf;
+	int result;
+
+	result = statfs(path, &statfs_buf);
+	if (result != 0) {
+		return result;
+	}
+	
+	statbuf->OptimalTransferSize = statfs_buf.f_iosize;
+	statbuf->BlockSize = statfs_buf.f_bsize;
+	statbuf->TotalBlocks = statfs_buf.f_blocks;
+	statbuf->BlocksAvail = statfs_buf.f_bfree;
+	statbuf->UserBlocksAvail = statfs_buf.f_bavail;
+	statbuf->TotalFileNodes = statfs_buf.f_files;
+	statbuf->FreeFileNodes = statfs_buf.f_ffree;
+	statbuf->FsIdentifier = 
+		(((uint64_t) statfs_buf.f_fsid.val[0] << 32) & 0xffffffff00000000LL) |
+		    (uint64_t) statfs_buf.f_fsid.val[1];
+	/* Try to extrapolate some of the fs flags into the
+	 * capabilities
+	 */
+	statbuf->FsCapabilities =
+	    FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+#ifdef MNT_ACLS
+	if (statfs_buf.f_flags & MNT_ACLS)
+		statbuf->FsCapabilities |= FILE_PERSISTENT_ACLS;
 #endif
+	if (statfs_buf.f_flags & MNT_QUOTA)
+		statbuf->FsCapabilities |= FILE_VOLUME_QUOTAS;
+	if (statfs_buf.f_flags & MNT_RDONLY)
+		statbuf->FsCapabilities |= FILE_READ_ONLY_VOLUME;
 
+	return 0;
+}
+#endif
+
 /* 
  sys_statvfs() is an abstraction layer over system-dependent statvfs()/statfs()
  for particular POSIX systems. Due to controversy of what is considered more important
@@ -139,6 +174,8 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *
 	return linux_statvfs(path, statbuf);
 #elif defined(DARWINOS)
 	return darwin_statvfs(path, statbuf);
+#elif defined(BSD) && defined(BSD_STATVFS_BSIZE)
+	return bsd_statvfs(path, statbuf);
 #else
 	/* BB change this to return invalid level */
 #ifdef EOPNOTSUPP
